home *** CD-ROM | disk | FTP | other *** search
/ Cream of the Crop 26 / Cream of the Crop 26.iso / program / wil4c10.zip / STR.C < prev    next >
C/C++ Source or Header  |  1997-07-26  |  1KB  |  48 lines

  1. /* str.c */
  2.  
  3. #include <windows.h>
  4. #include "str.h"
  5.  
  6. /* strip trailing CRLF from string */
  7.  
  8. void StripCRLF(LPSTR Buffer)
  9. {int Len;
  10.  Len = lstrlen((LPSTR)Buffer);
  11.  if(Len<2) return;
  12.  if((Buffer[Len-2]=='\r')&&(Buffer[Len-1]=='\n')) Buffer[Len-2] = '\0';
  13. }
  14.  
  15. /* copy string SrcPtr to DstPtr */
  16.  
  17. void StringCopy(LPSTR DstPtr, LPSTR SrcPtr, int MaxSize)
  18. {int i;
  19.  for(i=1;i<MaxSize;i++)
  20.    {*DstPtr++ = *SrcPtr;
  21.     if(*SrcPtr=='\0') break;
  22.     SrcPtr++;
  23.    }
  24.  *DstPtr = '\0';
  25. }
  26.  
  27. /* Find location of character Chr in StringPtr */
  28.  
  29. LPSTR StringChar(LPSTR StringPtr, char Ch)
  30. {
  31.  while(1)
  32.    {if((*StringPtr)==Ch) return StringPtr;
  33.     if((*StringPtr++)=='\0') return NULL;
  34.    }
  35. }
  36.  
  37. /* is S2 a left substring of S1 ? */
  38.  
  39. int IsLeftString(LPSTR S1, LPSTR S2)
  40. {char C1, C2;
  41.  while(1)
  42.    {C1 = *S1++;
  43.     C2 = *S2++;
  44.     if(C2=='\0') return TRUE;
  45.     if(C1!=C2) return FALSE;
  46.    }
  47. }
  48.